package com.tencent.mm.opensdk.openapi;

import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import com.tencent.mm.opensdk.channel.ChannelInfo;
import com.tencent.mm.opensdk.channel.MMessageActV2;

import com.tencent.mm.opensdk.modelbase.BaseReq;
import com.tencent.mm.opensdk.modelbase.BaseResp;
import com.tencent.mm.opensdk.modelbiz.*;
import com.tencent.mm.opensdk.modelmsg.*;
import com.tencent.mm.opensdk.modelpay.PayResp;
import com.tencent.mm.opensdk.utils.ILog;
import com.tencent.mm.opensdk.utils.Log;
import com.tencent.mm.opensdk.utils.TecentUtil;

final class WXApiImplV10 implements IWXAPI {
    private static final String TAG = "MicroMsg.SDK.WXApiImplV10";
    private Context context;
    private String appId;
    private boolean checkSignature = false;
    private boolean detached = false;
    private static String wxappPayEntryClassname = null;

    WXApiImplV10(Context paramContext, String paramString, boolean paramBoolean) {
        Log.d("MicroMsg.SDK.WXApiImplV10", "<init>, appId = " + paramString + ", checkSignature = " + paramBoolean);
        this.context = paramContext;
        this.appId = paramString;
        this.checkSignature = paramBoolean;
    }

    public final boolean registerApp(String paramString) {
        return registerApp(paramString, 0L);
    }

    public final boolean registerApp(String paramString, long paramLong) {
        if (this.detached) {
            throw new IllegalStateException("registerApp fail, WXMsgImpl has been detached");
        }
        if (!WXApiImplComm.validateAppSignatureForPackage(this.context, "com.tencent.mm", this.checkSignature)) {
            Log.e("MicroMsg.SDK.WXApiImplV10", "register app failed for wechat app signature check failed");
            return false;
        }
        Log.d("MicroMsg.SDK.WXApiImplV10", "registerApp, appId = " + paramString);
        if (paramString != null) {
            this.appId = paramString;
        }
        Log.d("MicroMsg.SDK.WXApiImplV10", "registerApp, appId = " + paramString);
        if (paramString != null) {
            this.appId = paramString;
        }
        Log.d("MicroMsg.SDK.WXApiImplV10", "register app " + this.context.getPackageName());

        ChannelInfo ci = new ChannelInfo();
        ci.a = "com.tencent.mm";
        ci.action = "com.tencent.mm.plugin.openapi.Intent.ACTION_HANDLE_APP_REGISTER";
        ci.content = ("weixin://registerapp?appid=" + this.appId);
        ci.b = paramLong;
        return ChannelInfo.validateParam(this.context, ci);
    }

    public final void unregisterApp() {
        if (this.detached) {
            throw new IllegalStateException("unregisterApp fail, WXMsgImpl has been detached");
        }
        if (!WXApiImplComm.validateAppSignatureForPackage(this.context, "com.tencent.mm", this.checkSignature)) {
            Log.e("MicroMsg.SDK.WXApiImplV10", "unregister app failed for wechat app signature check failed");
            return;
        }
        Log.d("MicroMsg.SDK.WXApiImplV10", "unregisterApp, appId = " + this.appId);
        if ((this.appId == null) || (this.appId.length() == 0)) {
            Log.e("MicroMsg.SDK.WXApiImplV10", "unregisterApp fail, appId is empty");
            return;
        }
        Log.d("MicroMsg.SDK.WXApiImplV10", "unregister app " + this.context.getPackageName());
        ChannelInfo locala = new ChannelInfo();
        locala.a = "com.tencent.mm";
        locala.action = "com.tencent.mm.plugin.openapi.Intent.ACTION_HANDLE_APP_UNREGISTER";
        locala.content = ("weixin://unregisterapp?appid=" + this.appId);
        ChannelInfo.validateParam(this.context, locala);
    }

    public final boolean handleIntent(Intent paramIntent, IWXAPIEventHandler paramIWXAPIEventHandler) {
        try {
            if (!WXApiImplComm.isIntentFromWx(paramIntent, "com.tencent.mm.openapi.token")) {
                Log.i("MicroMsg.SDK.WXApiImplV10", "handleIntent fail, intent not from weixin msg");
                return false;
            }
            if (this.detached) {
                throw new IllegalStateException("handleIntent fail, WXMsgImpl has been detached");
            }
            Object localObject = paramIntent.getStringExtra("_mmessage_content");
            int j = paramIntent.getIntExtra("_mmessage_sdkVersion", 0);
            String str2;
            if (((str2 = paramIntent.getStringExtra("_mmessage_appPackage")) == null) || (str2.length() == 0)) {
                Log.e("MicroMsg.SDK.WXApiImplV10", "invalid argument");
                return false;
            }
            byte[] arrayOfByte = paramIntent.getByteArrayExtra("_mmessage_checksum");
            byte[] checksums = ChannelInfo.checksum((String) localObject, j, str2);

            if (!checkSumConsistent(arrayOfByte, checksums)) {
                Log.e("MicroMsg.SDK.WXApiImplV10", "checksum fail");
                return false;
            }
            int i = paramIntent.getIntExtra("_wxapi_command_type", 0);
            Log.i("MicroMsg.SDK.WXApiImplV10", "handleIntent, cmd = " + i);
            String str1;

            BaseResp resp;
            BaseReq req;

            switch (i) {
                case 1:
                    resp = new SendAuth.Resp(paramIntent.getExtras());
                    paramIWXAPIEventHandler.onResp(resp);
                    return true;
                case 2:
                    resp = new SendMessageToWX.Resp(paramIntent.getExtras());
                    paramIWXAPIEventHandler.onResp(resp);
                    return true;
                case 3:
                    req = new GetMessageFromWX.Req(paramIntent.getExtras());
                    paramIWXAPIEventHandler.onReq(req);
                    return true;
                case 4:
                    ShowMessageFromWX.Req req1 = new ShowMessageFromWX.Req(paramIntent.getExtras());


                    if ((req1.message.messageExt != null) && (req1.message.messageExt.contains("wx_internal_resptype"))) {

                        boolean b = handleWxInternalRespType(req1.message.messageExt, paramIWXAPIEventHandler);
                        Log.i("MicroMsg.SDK.WXApiImplV10", "handleIntent, extInfo contains wx_internal_resptype, ret = " + paramIntent);
                        return b;
                    }
                    paramIWXAPIEventHandler.onReq(req1);
                    return true;
                case 5:

                    resp = new PayResp(paramIntent.getExtras());
                    paramIWXAPIEventHandler.onResp(resp);
                    return true;
                case 6:
                    req = new LaunchFromWX.Req(paramIntent.getExtras());
                    paramIWXAPIEventHandler.onReq(req);
                    return true;
                case 9:
                    resp = new AddCardToWXCardPackage.Resp(paramIntent.getExtras());
                    paramIWXAPIEventHandler.onResp(resp);
                    return true;
                case 16:
                    resp = new ChooseCardFromWXCardPackage.Resp(paramIntent.getExtras());
                    paramIWXAPIEventHandler.onResp(resp);
                    return true;
                case 14:
                    resp = new CreateChatroom.Resp(paramIntent.getExtras());
                    paramIWXAPIEventHandler.onResp(resp);
                    return true;
                case 15:
                    resp = new JoinChatroom.Resp(paramIntent.getExtras());
                    paramIWXAPIEventHandler.onResp(resp);
                    return true;
                case 12:
                    resp = new OpenWebview.Resp(paramIntent.getExtras());
                    paramIWXAPIEventHandler.onResp(resp);
                    return true;
                case 17:
                    resp = new HandleScanResult.Resp(paramIntent.getExtras());
                    paramIWXAPIEventHandler.onResp(resp);
                    return true;
            }

        } catch (Exception localException) {
            Log.e("MicroMsg.SDK.WXApiImplV10", "handleIntent fail, ex = " + localException.getMessage());
        }
        return false;
    }

    private boolean handleWxInternalRespType(String paramString, IWXAPIEventHandler paramIWXAPIEventHandler) {
        Log.i("MicroMsg.SDK.WXApiImplV10", "handleWxInternalRespType, extInfo = " + paramString);
        paramString = "http://www.qq.com/s?" + paramString;
        try {

            Uri uri = (Uri.parse(paramString));
            String local = uri.getQueryParameter("wx_internal_resptype");


            if (TecentUtil.isEmpty((String) local)) {
                Log.e("MicroMsg.SDK.WXApiImplV10", "handleWxInternalRespType fail, respType is null");
                return false;
            }


            if (local.equals("subscribemessage")) {

                SubscribeMessage.Resp resp = new SubscribeMessage.Resp();

                resp.openId = uri.getQueryParameter("openid");


                resp.templateID = uri.getQueryParameter("template_id");
                resp.scene = TecentUtil.s2i(uri.getQueryParameter("scene"));
                resp.action = uri.getQueryParameter("action");
                resp.reserved = uri.getQueryParameter("reserved");
                paramIWXAPIEventHandler.onResp(resp);
                return true;
            }

        } catch (Exception e) {
            Log.e("MicroMsg.SDK.WXApiImplV10", "handleWxInternalRespType fail, ex = " + e.getMessage());
        }
        return false;
    }

    public final boolean isWXAppInstalled() {
        if (this.detached) {
            throw new IllegalStateException("isWXAppInstalled fail, WXMsgImpl has been detached");
        }
        try {
            PackageInfo localPackageInfo;
            if ((localPackageInfo = this.context.getPackageManager().getPackageInfo("com.tencent.mm", 64)) == null) {
                return false;
            }
            return WXApiImplComm.validateAppSignature(this.context, localPackageInfo.signatures, this.checkSignature);
        } catch (PackageManager.NameNotFoundException localNameNotFoundException) {
        }
        return false;
    }

    public final boolean isWXAppSupportAPI() {
        if (this.detached) {
            throw new IllegalStateException("isWXAppSupportAPI fail, WXMsgImpl has been detached");
        }
        return getWXAppSupportAPI() >= 620756998;
    }

    public final int getWXAppSupportAPI() {
        if (this.detached) {
            throw new IllegalStateException("getWXAppSupportAPI fail, WXMsgImpl has been detached");
        }
        if (!isWXAppInstalled()) {
            Log.e("MicroMsg.SDK.WXApiImplV10", "open wx app failed, not installed or signature check failed");
            return 0;
        }
        int i;
        if ((i = new MMSharedPreferences(this.context).getInt("_build_info_sdk_int_", 0)) == 0) {
            try {
                i = this.context.getPackageManager().getApplicationInfo("com.tencent.mm", 128).metaData.getInt("com.tencent.mm.BuildInfo.OPEN_SDK_VERSION", 0);
            } catch (Exception localException) {
                Log.e("MicroMsg.SDK.WXApiImplV10", "get from metaData failed : " + localException.getMessage());
            }
        }
        return i;
    }

    public final boolean openWXApp() {
        if (this.detached) {
            throw new IllegalStateException("openWXApp fail, WXMsgImpl has been detached");
        }
        if (!isWXAppInstalled()) {
            Log.e("MicroMsg.SDK.WXApiImplV10", "open wx app failed, not installed or signature check failed");
            return false;
        }
        try {
            this.context.startActivity(this.context.getPackageManager().getLaunchIntentForPackage("com.tencent.mm"));
        } catch (Exception localException) {
            Log.e("MicroMsg.SDK.WXApiImplV10", "startActivity fail, exception = " + localException.getMessage());
            return false;
        }
        return true;
    }

    public final boolean sendReq(BaseReq paramBaseReq) {
        if (this.detached) {
            throw new IllegalStateException("sendReq fail, WXMsgImpl has been detached");
        }
        if (!WXApiImplComm.validateAppSignatureForPackage(this.context, "com.tencent.mm", this.checkSignature)) {
            Log.e("MicroMsg.SDK.WXApiImplV10", "sendReq failed for wechat app signature check failed");
            return false;
        }
        if (!paramBaseReq.checkArgs()) {
            Log.e("MicroMsg.SDK.WXApiImplV10", "sendReq checkArgs fail");
            return false;
        }
        Log.i("MicroMsg.SDK.WXApiImplV10", "sendReq, req type = " + paramBaseReq.getType());
        Bundle localBundle = new Bundle();
        paramBaseReq.toBundle(localBundle);
        if (paramBaseReq.getType() == 5) {
            return sendPayReq(this.context, localBundle);
        }
        if (paramBaseReq.getType() == 7) {
            return sendJumpToBizProfileReq(this.context, localBundle);
        }
        if (paramBaseReq.getType() == 8) {
            return sendJumpToBizWebviewReq(this.context, localBundle);
        }
        if (paramBaseReq.getType() == 10) {
            return sendJumpToBizTempSessionReq(this.context, localBundle);
        }
        if (paramBaseReq.getType() == 9) {
            return sendAddCardToWX(this.context, localBundle);
        }
        if (paramBaseReq.getType() == 16) {
            return sendChooseCardFromWX(this.context, localBundle);
        }
        if (paramBaseReq.getType() == 11) {
            return sendOpenRankListReq(this.context, localBundle);
        }
        if (paramBaseReq.getType() == 12) {
            return sendOpenWebview(this.context, localBundle);
        }
        if (paramBaseReq.getType() == 13) {
            return sendOpenBusiLuckyMoney(this.context, localBundle);
        }
        if (paramBaseReq.getType() == 14) {
            return createChatroom(this.context, localBundle);
        }
        if (paramBaseReq.getType() == 15) {
            return joinChatroom(this.context, localBundle);
        }
        if (paramBaseReq.getType() == 17) {
            return sendHandleScanResult(this.context, localBundle);
        }
        if (paramBaseReq.getType() == 18) {
            return sendSubscribeMessage(this.context, paramBaseReq);
        }
        Object localObject1;
        if ((paramBaseReq.getType() == 2) && (localBundle.getInt("_wxapi_sendmessagetowx_req_media_type") == 36)) {
            localObject1 = paramBaseReq;
            Object localObject2;
            if (getWXAppSupportAPI() < 620756993) {


                WXWebpageObject wxWebpageObject = new WXWebpageObject();


                wxWebpageObject.webpageUrl = localBundle.getString("_wxminiprogram_webpageurl");


                ((SendMessageToWX.Req) localObject1).message.mediaObject = ((WXMediaMessage.IMediaObject) wxWebpageObject);
            } else {
                WXMiniProgramObject wxWebpageObject = (WXMiniProgramObject) ((SendMessageToWX.Req) localObject1).message.mediaObject;
                wxWebpageObject.userName += "@app";


                if (!TecentUtil.isEmpty(wxWebpageObject.path)) {

                    Object[] localObject3 = wxWebpageObject.path.split("\\?");

                    String result = "";


                    if (localObject3.length > 1) {
                        result = localObject3[0] + ".html?" + localObject3[1];
                    } else {
                        result = localObject3[0] + ".html";
                    }
                    wxWebpageObject.path = result;
                }
            }
            ((SendMessageToWX.Req) localObject1).scene = 0;
            paramBaseReq.toBundle(localBundle);
        }

        MMessageActV2.Args args = new MMessageActV2.Args();

        args.bundle = localBundle;


        args.content = ("weixin://sendreq?appid=" + this.appId);
        args.targetPkgName = "com.tencent.mm";
        args.targetClassName = "com.tencent.mm.plugin.base.stub.WXEntryActivity";
        return MMessageActV2.send(this.context, args);
    }

    private boolean sendPayReq(Context paramContext, Bundle paramBundle) {
        if (wxappPayEntryClassname == null) {
            wxappPayEntryClassname = new MMSharedPreferences(paramContext).getString("_wxapp_pay_entry_classname_", null);
            Log.d("MicroMsg.SDK.WXApiImplV10", "pay, set wxappPayEntryClassname = " + wxappPayEntryClassname);
            if (wxappPayEntryClassname == null) {
                try {
                    wxappPayEntryClassname = paramContext.getPackageManager().getApplicationInfo("com.tencent.mm", 128).metaData.getString("com.tencent.mm.BuildInfo.OPEN_SDK_PAY_ENTRY_CLASSNAME", null);
                } catch (Exception localException) {
                    Log.e("MicroMsg.SDK.WXApiImplV10", "get from metaData failed : " + localException.getMessage());
                }
            }
            if (wxappPayEntryClassname == null) {
                Log.e("MicroMsg.SDK.WXApiImplV10", "pay fail, wxappPayEntryClassname is null");
                return false;
            }
        }
        MMessageActV2.Args localArgs;
        (localArgs = new MMessageActV2.Args()).bundle = paramBundle;
        localArgs.targetPkgName = "com.tencent.mm";
        try {
            localArgs.targetClassName =
                    paramContext.getPackageManager().getApplicationInfo("com.tencent.mm", 128).metaData.getString("com.tencent.mm.BuildInfo.OPEN_SDK_PAY_ENTRY_CLASSNAME", null);
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }

        return MMessageActV2.send(paramContext, localArgs);
    }

    private boolean sendJumpToBizProfileReq(Context paramContext, Bundle paramBundle) {
        ContentResolver resolver = paramContext.getContentResolver();
        Uri localUri = Uri.parse("content://com.tencent.mm.sdk.comm.provider/jumpToBizProfile");
        String[] ss = new String[]{this.appId, paramBundle.getString("_wxapi_jump_to_biz_profile_req_to_user_name"), paramBundle.getString("_wxapi_jump_to_biz_profile_req_ext_msg"),
                paramBundle.getInt("_wxapi_jump_to_biz_profile_req_scene")+"", ""+paramBundle.getInt("_wxapi_jump_to_biz_profile_req_profile_type")};
        Cursor cursor = resolver.query(localUri, null, null, ss, null);


        if (cursor != null) {
            cursor.close();
        }
        return true;
    }

    private boolean sendJumpToBizWebviewReq(Context paramContext, Bundle paramBundle) {
        ContentResolver resolver = paramContext.getContentResolver();
        Uri localUri = Uri.parse("content://com.tencent.mm.sdk.comm.provider/jumpToBizProfile");
        String [] ss = new String[]{this.appId, paramBundle.getString("_wxapi_jump_to_biz_webview_req_to_user_name"),
                paramBundle.getString("_wxapi_jump_to_biz_webview_req_ext_msg"),
                ""+paramBundle.getInt("_wxapi_jump_to_biz_webview_req_scene")};
        Cursor cursor=resolver.query(localUri, null, null, ss, null);

        if (cursor != null) {
            cursor.close();
        }
        return true;
    }

    private boolean sendJumpToBizTempSessionReq(Context paramContext, Bundle paramBundle) {
        ContentResolver resolver = paramContext.getContentResolver();
        Uri localUri = Uri.parse("content://com.tencent.mm.sdk.comm.provider/jumpToBizTempSession");
        String[] ss = new String[]{this.appId, paramBundle.getString("_wxapi_jump_to_biz_webview_req_to_user_name"), paramBundle.getString("_wxapi_jump_to_biz_webview_req_session_from"), ""+paramBundle.getInt("_wxapi_jump_to_biz_webview_req_show_type")};
        Cursor query = resolver.query(localUri, null, null, ss, null);
        if (query  != null) {
            query.close();
        }
        return true;
    }

    private boolean sendAddCardToWX(Context paramContext, Bundle paramBundle) {
        ContentResolver resolver = paramContext.getContentResolver();
        Uri localUri = Uri.parse("content://com.tencent.mm.sdk.comm.provider/addCardToWX");
        String[] ss = new String[]{this.appId, paramBundle.getString("_wxapi_add_card_to_wx_card_list"), paramBundle.getString("_wxapi_basereq_transaction")};
        Cursor query = resolver.query(localUri, null, null, ss, null);
        if (query  != null) {
            query.close();
        }
        return true;
    }

    private boolean sendChooseCardFromWX(Context paramContext, Bundle paramBundle) {
        ContentResolver resolver = paramContext.getContentResolver();
        Uri localUri = Uri.parse("content://com.tencent.mm.sdk.comm.provider/chooseCardFromWX");
        String[] ss = new String[]{paramBundle.getString("_wxapi_choose_card_from_wx_card_app_id"), paramBundle.getString("_wxapi_choose_card_from_wx_card_location_id"), paramBundle.getString("_wxapi_choose_card_from_wx_card_sign_type"), paramBundle.getString("_wxapi_choose_card_from_wx_card_card_sign"), paramBundle.getString("_wxapi_choose_card_from_wx_card_time_stamp"), paramBundle.getString("_wxapi_choose_card_from_wx_card_nonce_str"), paramBundle.getString("_wxapi_choose_card_from_wx_card_card_id"), paramBundle.getString("_wxapi_choose_card_from_wx_card_card_type"), paramBundle.getString("_wxapi_choose_card_from_wx_card_can_multi_select"), paramBundle.getString("_wxapi_basereq_transaction")};

        Cursor query = resolver.query(localUri, null, null, ss, null);
        if (query  != null) {
            query.close();
        }
        return true;
    }

    private boolean sendOpenRankListReq(Context paramContext, Bundle paramBundle) {
        ContentResolver resolver = paramContext.getContentResolver();
        Uri parse = Uri.parse("content://com.tencent.mm.sdk.comm.provider/openRankList");
        String[] arrayOfString = new String[0];
        Cursor query = resolver.query(parse, null, null, arrayOfString, null);
        if (query  != null) {
            query.close();
        }
        return true;
    }

    private boolean sendOpenWebview(Context paramContext, Bundle paramBundle) {
        ContentResolver resolver = paramContext.getContentResolver();
        Uri localUri = Uri.parse("content://com.tencent.mm.sdk.comm.provider/openWebview");
       String[] ss= new String[]{this.appId, paramBundle.getString("_wxapi_jump_to_webview_url"), paramBundle.getString("_wxapi_basereq_transaction")};


        Cursor query = resolver.query(localUri, null, null, ss, null);
        if (query  != null) {
            query.close();
        }

        return true;
    }

    private boolean sendOpenBusiLuckyMoney(Context paramContext, Bundle paramBundle) {
        ContentResolver resolver = paramContext.getContentResolver();
        Uri localUri = Uri.parse("content://com.tencent.mm.sdk.comm.provider/openBusiLuckyMoney");
        String[] ss = new String[]{this.appId, paramBundle.getString("_wxapi_open_busi_lucky_money_timeStamp"), paramBundle.getString("_wxapi_open_busi_lucky_money_nonceStr"), paramBundle.getString("_wxapi_open_busi_lucky_money_signType"), paramBundle.getString("_wxapi_open_busi_lucky_money_signature"), paramBundle.getString("_wxapi_open_busi_lucky_money_package")};
        Cursor query = resolver.query(localUri, null, null, ss, null);
        if (query  != null) {
            query.close();
        }
        return true;
    }

    private boolean createChatroom(Context paramContext, Bundle paramBundle) {
        ContentResolver resolver = paramContext.getContentResolver();
        Uri localUri = Uri.parse("content://com.tencent.mm.sdk.comm.provider/createChatroom");
        String[] ss = new String[]{this.appId, paramBundle.getString("_wxapi_basereq_transaction", ""), paramBundle.getString("_wxapi_create_chatroom_group_id", ""), paramBundle.getString("_wxapi_create_chatroom_chatroom_name", ""), paramBundle.getString("_wxapi_create_chatroom_chatroom_nickname", ""), paramBundle.getString("_wxapi_create_chatroom_ext_msg", ""), paramBundle.getString("_wxapi_basereq_openid", "")};
        Cursor query = resolver.query(localUri, null, null, ss, null);
        if (query  != null) {
            query.close();
        }
        return true;
    }

    private boolean joinChatroom(Context paramContext, Bundle paramBundle) {
        ContentResolver resolver = paramContext.getContentResolver();
        Uri localUri = Uri.parse("content://com.tencent.mm.sdk.comm.provider/joinChatroom");
        String [] ss = new String[]{this.appId, paramBundle.getString("_wxapi_basereq_transaction", ""), paramBundle.getString("_wxapi_join_chatroom_group_id", ""), paramBundle.getString("_wxapi_join_chatroom_chatroom_nickname", ""), paramBundle.getString("_wxapi_join_chatroom_ext_msg", ""), paramBundle.getString("_wxapi_basereq_openid", "")};
        Cursor query = resolver.query(localUri, null, null, ss, null);
        if (query  != null) {
            query.close();
        }
        return true;
    }

    private boolean sendHandleScanResult(Context paramContext, Bundle paramBundle) {
        ContentResolver resolver = paramContext.getContentResolver();
        Uri localUri = Uri.parse("content://com.tencent.mm.sdk.comm.provider/handleScanResult");
        String []ss = new String[]{this.appId, paramBundle.getString("_wxapi_scan_qrcode_result")};

        Cursor query = resolver.query(localUri, null, null, ss, null);
        if (query != null) {
            query.close();
        }
        return true;
    }

    private boolean sendSubscribeMessage(Context paramContext, BaseReq paramBaseReq) {
        SubscribeMessage.Req req = (SubscribeMessage.Req) paramBaseReq;
        ContentResolver resolver = paramContext.getContentResolver();
        Uri localUri = Uri.parse("content://com.tencent.mm.sdk.comm.provider/openTypeWebview");
        String[] ss = new String[]{this.appId, "1", String.valueOf(req.scene), req.templateID, req.reserved};

        Cursor query = resolver.query(localUri, null, null, ss, null);
        if (ss != null) {
            query.close();
        }
        return true;
    }

    public final boolean sendResp(BaseResp paramBaseResp) {
        if (this.detached) {
            throw new IllegalStateException("sendResp fail, WXMsgImpl has been detached");
        }
        if (!WXApiImplComm.validateAppSignatureForPackage(this.context, "com.tencent.mm", this.checkSignature)) {
            Log.e("MicroMsg.SDK.WXApiImplV10", "sendResp failed for wechat app signature check failed");
            return false;
        }
        if (!paramBaseResp.checkArgs()) {
            Log.e("MicroMsg.SDK.WXApiImplV10", "sendResp checkArgs fail");
            return false;
        }
        Bundle localBundle = new Bundle();
        paramBaseResp.toBundle(localBundle);
        MMessageActV2.Args args = new MMessageActV2.Args();


        args.bundle = localBundle;
        args.content = ("weixin://sendresp?appid=" + this.appId);
        args.targetPkgName = "com.tencent.mm";
        args.targetClassName = "com.tencent.mm.plugin.base.stub.WXEntryActivity";
        return MMessageActV2.send(this.context, args);
    }

    public final void detach() {
        Log.d("MicroMsg.SDK.WXApiImplV10", "detach");
        this.detached = true;
        this.context = null;
    }

    public final void setLogImpl(ILog paramILog) {
        Log.setLogImpl(paramILog);
    }

    private boolean checkSumConsistent(byte[] paramArrayOfByte1, byte[] paramArrayOfByte2) {
        if ((paramArrayOfByte1 == null) || (paramArrayOfByte1.length == 0) || (paramArrayOfByte2 == null) || (paramArrayOfByte2.length == 0)) {
            Log.e("MicroMsg.SDK.WXApiImplV10", "checkSumConsistent fail, invalid arguments");
            return false;
        }
        if (paramArrayOfByte1.length != paramArrayOfByte2.length) {
            Log.e("MicroMsg.SDK.WXApiImplV10", "checkSumConsistent fail, length is different");
            return false;
        }
        for (int i = 0; i < paramArrayOfByte1.length; i++) {
            if (paramArrayOfByte1[i] != paramArrayOfByte2[i]) {
                return false;
            }
        }
        return true;
    }
}



